home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 1992 August
/
info-mac-1992.iso
/
Applications (app)
/
STvi
/
stevie 3.10
/
crt0.asm
< prev
next >
Wrap
Assembly Source File
|
1991-01-03
|
3KB
|
168 lines
; 32-bit clean version of crt0.asm for Aztec C, v 3.6c.
; Reference, Technote #212.
; Don't walk the resource map, don't mask pointers, don't write
; to your code block.
; Earle R. Horton 4/10/89
saveH EQU 0 ; Stack frame vars
CurJtOffset equ $0934
macro _GetResource
dc.w $A9A0
endm
macro _DetachResource
dc.w $A992
endm
macro _LoadResource
dc.w $A9A2
endm
macro _StripAddress
dc.w $A055
endm
macro _GetTrapAddress
dc.w $A146|%1
endm
macro _Debugger
dc.w $A9FF
endm
macro _BlockMove
dc.w $A02E
endm
macro _ReleaseResource
dc.w $A9A3
endm
macro _HLock
dc.w $A029
endm
macro _GetHandleSize
dc.w $A025
endm
StripAddressTrap equ $0055
UnimplementedTrap equ $009F
newOS equ $0200
newTool equ $0600
ROM85 equ $028E
public __Dorg
public __Uorg
public __Uend
public _Croot
entry .begin
public .begin
public _UnloadSeg
.begin
LINK A6,#saveH
SUBQ #4,A7
MOVE.L #'CODE',D3 ; D3 = 'CODE'
MOVE.L D3,-(sp)
MOVE.W #1,-(sp)
_GetResource
MOVE.L (sp)+,A2
MOVE.L (A2),D6 ; D6 = start of 'CODE' 1
tst.w ROM85 ; Check for _NGetTrapAddress
bmi.s stripit ; pre-128k ROMs
move.w #StripAddressTrap,d0 ; Check for _StripAddress trap.
_GetTrapAddress newOS
MOVE.L A0,A1
move.w #UnimplementedTrap,d0
_GetTrapAddress 0
CMPA.L A1,A0
BEQ.S stripit ; No StripAddress
MOVE.L D6,D0
_StripAddress
MOVE.L D0,D6
BRA.S stripped
stripit
AND.L #$FFFFFF,D6 ; Mask low 3 bytes.
stripped
SUBQ #4,A7 ; Load initialized data from 'CODE' 256.
MOVE.L D3,-(sp)
move.w #256,-(sp)
_GetResource
movea.l (sp),a2
move.l a2,d0
beq.s do257
_LoadResource
movea.l a2,a0
_HLock
movea.l a2,a0
_GetHandleSize
move.l (a2),a0
movea.l a5,a1
suba.l #(__Uend-__Dorg),a1
_BlockMove
move.l a2,-(sp)
_ReleaseResource
do257
ADDQ.L #4,D6
subq #4,sp ;; Load relocation data from 'CODE' 257.
move.l D3,-(sp)
move.w #257,-(sp)
_GetResource
move.l (sp),D3 ; D3 = Handle to 'CODE' 257
beq.s clear_udata
_LoadResource
move.l D3,a0
_GetHandleSize
tst.l d0
beq clear_udata
movea.l (a2),a1 ; a1 -> start of relocation data
MOVEA.L A5,A2
MOVE.L A5,D4
BSR.S relocate
MOVE.L D6,D4
BSR.S relocate
MOVEA.L D6,A2
MOVE.L A5,D4
BSR.S relocate
MOVE.L D6,D4
BSR.S relocate
LEA 4(A5),A3
ADDA.W CurJtOffset,A3
move.l (a1)+,d1
BMI.S clear_udata
loop1 move.l (a1)+,d2
ADD.L D6,D2
MOVE.L D2,(A3)
ADDQ.L #8,A3
DBRA D1,loop1
clear_udata
MOVE.L #((__Uend-__Uorg)/2)-1,D0
BMI.S cleanup
MOVEA.L A5,A0
SUBA.L #(__Uend-__Uorg),A0
loop2 CLR (A0)+
DBRA D0,loop2
cleanup
tst.l D3
beq.s done
move.l D3,-(sp)
_ReleaseResource
done
SUBQ #4,A7
MOVE.L #'CODE',(sp)
CLR.W -(sp)
_GetResource
_ReleaseResource
UNLK A6
JMP _Croot
UNLK A6
RTS
DC.B 'crt0 '
relocate
move.l (a1)+,d0
BMI.S lac_2
lac_1 move.l (a1)+,d1
ADD.L D4,0(A2,D1.L)
DBRA D0,lac_1
lac_2 RTS
_UnloadSeg
DC.W $ADF1
end